#!/usr/bin/perl -ws
$trace = (defined($t) && ($t eq "1"));
$sdir = "/src/";
$psdir = "/presrc/";
$testpsdir = "/testpresrc/";
%file_names = ();
{
$test1 = <<'EOD'
/opt/WTK2.5.1/apps/RSSReader/mobile-rss-reader/presrc/com/substanceofcode/rssreader/presentation/RssReaderMIDlet.java
/opt/WTK2.5.1/apps/RSSReader/mobile-rss-reader/src/com/substanceofcode/rssreader/presentation/RssReaderMIDlet.java
/opt/WTK2.5.1/apps/RSSReader/mobile-rss-reader/src/com/substanceofcode/testutil/presentation/TestingForm.java
/opt/WTK2.5.1/apps/RSSReader/mobile-rss-reader/testpresrc/com/substanceofcode/testutil/presentation/TestingForm.java
EOD
};
#foreach $line (split("\n", $test1)) {
# $line = "$line\n";
#    $trace = 1; #undo
while (defined ($line = <>)) {
 	$file_names{$line} = 1;
};
foreach $file (keys(%file_names)) {
	$nfile = $file;
	if ($trace) {
		print "file=$file";
	}
	if (($pos = index($nfile, $sdir)) > 0) {
		$new_file = substr($nfile, 0, $pos) . $psdir .
			substr($nfile, $pos + length($sdir));
		if ($trace) {
			print "new_file=$new_file\n";
		}
		if (exists($file_names{$new_file})) {
			$file_names{$file} = 0;
			if ($trace) {
				print "new_file exists=$new_file\n";
			}
		} else {
			$new_file = substr($nfile, 0, $pos) . $testpsdir .
			substr($nfile, $pos + length($sdir));
			if ($trace) {
				print "new_file=$new_file\n";
			}
			if (exists($file_names{$new_file})) {
				$file_names{$file} = 0;
				if ($trace) {
					print "new_file exists=$new_file\n";
				}
			};
		};
	} else {
		if ($trace) {
			print "pos=$pos\n";
		}
	};
}
foreach $file (sort(keys(%file_names))) {
	if ($file_names{$file} == 1) {
		print $file;
	}
}

exit 0;
print "$test1\n";
